package edu.ctbu.insurance.service.impl;

import com.github.pagehelper.PageHelper;
import edu.ctbu.insurance.bean.Policy;
import edu.ctbu.insurance.mapper.PolicyMapper;
import edu.ctbu.insurance.service.PolicyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author djl
 * @since 2024-06-28
 */
@Service
@Transactional
public class PolicyServiceImpl extends ServiceImpl<PolicyMapper, Policy> implements PolicyService {
    @Autowired
    PolicyMapper  policyMapper;

    @Override
    public List<Policy> findPolicysByLike(String likeProductName, String likeCustomerName, String likePolicyType) {
        return policyMapper.findPolicysByLike(likePolicyType,likeProductName,likeCustomerName);
    }

    @Override
    public List<Policy> findPolicysPageByLike(String likePolicyType, int pageNum, int pageSize, String likeProductName, String likeCustomerName) {
        PageHelper.startPage(pageNum,pageSize);//开启分页
        return policyMapper.findPolicysByLike(likePolicyType,likeProductName,likeCustomerName);
    }

    @Override
    public int updatePolicyStatus() {
        return policyMapper.updatePolicyStatus();
    }

    @Override
    public List<Object> getProductStatistics() {
        return policyMapper.getProductStatistics();
    }

    @Override
    public List<Object> getCustomerStatistics() {
        return policyMapper.getCustomerStatistics();
    }

    @Override
    public List<Object> getAddressStatistics() {
        return policyMapper.getAddressStatistics();
    }
}
